let el_ct="";
let main=document.querySelector('#main')
let maindv=document.querySelector('.main_dv')
fetch("http://chst.vip:1234/api/getcategorytitle")
.then(body=>body.json())
.then(res=>{
    // console.log(res.result)
    res.result.forEach(item=>{
        el_ct+=`<div>
    <h4 titleid="${item.titleId}">
        <a titleid="${item.titleId}">
            <span titleid="${item.titleId}">${item.title}</span>
            <i class="fr" titleid="${item.titleId}">▼</i>
        </a>
    </h4>
    <div class="content"></div>
    </div>
    
`})
    main.innerHTML=el_ct;

    main.onclick=function(e){
        if(e.target.localName="h4"){
            let _this=e.target;
            let id=_this.getAttribute('titleid');
            console.log(id)
            location.href="./../pages/category.html?titleid="+id;       
        }    
    }
    let id=getQueryString('titleid');
    let el_minc="";
    // let content=document.querySelector('.content')
    
        fetch("http://chst.vip:1234/api/getcategory?titleid="+id)
        .then(body=>body.json())
        .then(res=>{
            console.log(res.result)
            res.result.forEach(item=>{
                el_minc+=`
                <a href="#">${item.category}</a>` 
            })
            console.log(el_minc)
            $('#main').find('.content').html(el_minc)
            
        })
})


    
    

    
    








